﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using xplang.abstractions;
using xplang.run;
using xplang.contexts;
using xplang.parse;

namespace xplang.rtl
{
  public class RTL : NativeContext
  {

    public static xplang.rtl.native.VoidClass voidClass = new xplang.rtl.native.VoidClass();

    public static GenericParamDecl indexParamType = new GenericParamDecl("I", null);
    public static GenericParamDecl rightParamType = new GenericParamDecl("T", null);
    public static Variable indexParam = new Variable(Modifier.None, "index", indexParamType.getRef(), null);
    public static Variable rightParam = new Variable(Modifier.None, "right", rightParamType.getRef(), null);

    public static xplang.rtl.operators.EquatableClass equatableClass = new xplang.rtl.operators.EquatableClass();
    public static xplang.rtl.operators.ComparableClass comparableClass = new xplang.rtl.operators.ComparableClass();

    public static xplang.rtl.operators.AddableClass addableClass = new xplang.rtl.operators.AddableClass();
    public static xplang.rtl.operators.SubtractableClass subtractableClass = new xplang.rtl.operators.SubtractableClass();
    public static xplang.rtl.operators.IncrementableClass incrementableClass = new xplang.rtl.operators.IncrementableClass();
    public static xplang.rtl.operators.DecrementableClass decrementableClass = new xplang.rtl.operators.DecrementableClass();

    public static xplang.rtl.native.ObjectClass objectClass = new xplang.rtl.native.ObjectClass();
    public static xplang.rtl.native.UndefinedClass undefinedClass = new xplang.rtl.native.UndefinedClass();
    public static xplang.rtl.native.BooleanClass booleanClass = new xplang.rtl.native.BooleanClass();
    public static xplang.rtl.native.IntClass intClass = new xplang.rtl.native.IntClass();
    public static xplang.rtl.native.DoubleClass doubleClass = new xplang.rtl.native.DoubleClass();
    public static xplang.rtl.native.StringClass stringClass = new xplang.rtl.native.StringClass();

    public static RTL rtl = new RTL();
    public static Variable undefinedVariable;

    internal RTL()
      : base(null, "system", null)
    {
    }

    public override NativeContext[] requirements()
    {
      return new NativeContext[] { };
    }

    public override NativeClass[] declarations()
    {
      NativeClass[] types = new NativeClass[]{
      voidClass,
      equatableClass, comparableClass,
      addableClass, subtractableClass,
      incrementableClass,decrementableClass,
      objectClass, booleanClass,
      intClass, doubleClass, stringClass
      };
      undefinedVariable = new Variable(Modifier.None, "?undefined?", voidClass.getRef(null), null);
      return types;
    }

  }
}
